package com.IR.user.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.IR.oss.util.MyDateProcessor;
import com.IR.shop.po.Collects;
import com.IR.user.service.BCollectsBiz;

import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;

@Controller
public class BCollectsAction {

	@Resource
	public BCollectsBiz biz;
	private Collects collects;
	private List<Collects> list;
	
	public Collects getCollects() {
		return collects;
	}

	public void setCollects(Collects collects) {
		this.collects = collects;
	}

	public List<Collects> getList() {
		return list;
	}

	public void setList(List<Collects> list) {
		this.list = list;
	}

	@RequestMapping(value="showCollectAll.do")
	public void showCollectsAll(HttpServletRequest request,HttpServletResponse response) throws IOException {
		response.setHeader("Access-Control-Allow-Origin", "*");
		response.setCharacterEncoding("utf-8");
		Long userid=new Long(request.getParameter("userid"));
		list=biz.showCollects(userid);
		PrintWriter out = response.getWriter();
		//MyDateProcessor mydate=new MyDateProcessor();
		MyDateProcessor mydate=new MyDateProcessor("yyyy-MM-dd HH:mm:ss");
		JsonConfig config=new JsonConfig();
		config.registerJsonValueProcessor("cdate", mydate);
		String str=JSONArray.fromObject(list,config).toString();
		out.println(str);
	}
	
}
